import 'package:flutter/material.dart';
import 'package:jg_docs/utils.dart/utils.dart';

class CatalogPage extends StatelessWidget {
  final List<String> dartFiles = [
    'route.dart',
    'route_information_parser.dart',
    'route_information_provider.dart',
    'router_delegate.dart',
    'routes.dart',
  ];

  final List<String> readmes = [
    'README.md',
    'assets/app_performance_monitor.md',
    'assets/energy_performance.md',
  ];
  final List<String> metrics = [
    'location',
    'cpu',
    'gpu',
    'memory',
    'display',
    'diskIo',
    'network',
    'launch',
    'time',
    'responsiveness',
    'Signpost',
    'cellularCondition',
  ];

  CatalogPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.white,
      child: ListView(
        children: [
          SizedBox(
            height: 60.0,
          ),
          Center(
            child: CircleAvatar(
              minRadius: 60.0,
              child: FlutterLogo(),
            ),
          ),
          SizedBox(
            height: 60.0,
          ),
          Divider(),
          ListTile(
            title: Text('settings'),
            trailing: Icon(Icons.arrow_right),
            onTap: () {},
          ),
          Divider(),
          ExpansionTile(
            title: Text('docs menu'),
            children: [
              ...readmes
                  .map(
                    (readme) => ListTile(
                      title: Padding(
                        padding: EdgeInsets.fromLTRB(20, 0, 0, 0),
                        child: Text('$readme'),
                      ),
                      trailing: Icon(Icons.arrow_right),
                      onTap: () {
                        TopicCenter().send(
                          Topic()
                            ..value = readme
                            ..channel = TopicChannel.docs,
                        );
                      },
                    ),
                  )
                  .toList(),
            ],
          ),
          ExpansionTile(
            title: Text('metrics'),
            children: [
              ...metrics
                  .map(
                    (metric) => ListTile(
                      title: Padding(
                        padding: EdgeInsets.fromLTRB(20, 0, 0, 0),
                        child: Text('$metric'),
                      ),
                      trailing: Icon(Icons.arrow_right),
                      onTap: () {
                        TopicCenter().send(
                          Topic()
                            ..value = metric
                            ..channel = TopicChannel.metrics,
                        );
                      },
                    ),
                  )
                  .toList(),
            ],
          ),
          Divider(),
          ExpansionTile(
            title: Text('route 2.0'),
            children: [
              ...dartFiles
                  .map(
                    (filePath) => ListTile(
                      title: Padding(
                        padding: EdgeInsets.fromLTRB(20, 0, 0, 0),
                        child: Text('$filePath'),
                      ),
                      trailing: Icon(Icons.arrow_right),
                      onTap: () {
                        TopicCenter().send(
                          Topic()
                            ..value = 'lib/route/$filePath'
                            ..channel = TopicChannel.docs,
                        );
                      },
                    ),
                  )
                  .toList(),
            ],
          ),
        ],
      ),
    );
  }
}
